package com.devenv.controller;

import com.devenv.common.Result;
import com.devenv.entity.Software;
import com.devenv.service.SoftwareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 公共API控制器
 */
@RestController
@RequestMapping("/api/public")
public class PublicController {

    @Autowired
    private SoftwareService softwareService;

    @GetMapping("/software")
    public Result<List<Software>> getSoftwareList() {
        try {
            List<Software> softwareList = softwareService.findAllActive();
            return Result.success(softwareList);
        } catch (Exception e) {
            return Result.error("获取软件列表失败: " + e.getMessage());
        }
    }
    
    @GetMapping("/info")
    public Result<Object> getSystemInfo() {
        return Result.success("DevEnv OpenSource Edition - 智能开发环境配置工具");
    }
}
